package com.leng.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leng.admin.mapper.AdminUserMapper;
import com.leng.admin.service.IUserService;
import com.leng.common.core.entity.admin.domain.AdminUser;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements IUserService {


    private LambdaQueryWrapper<AdminUser>  getLambdaQueryWrapper(){
        return Wrappers.lambdaQuery() ;
    }

    public void addQueryArgs(LambdaQueryWrapper<AdminUser> lwq){
        lwq.eq(AdminUser::getIsDeleted,0);
        lwq.eq(AdminUser::getStatus,0);
    }
    /**
     * 根据用户名查询账号信息
     * @param username
     * @return
     */
    @Override
    public AdminUser selectUserByUserName(String username) {
        LambdaQueryWrapper<AdminUser> lwq = getLambdaQueryWrapper();
        lwq.eq(AdminUser::getUsername,username);
        addQueryArgs(lwq);
        return getOne(lwq);
    }
}
